package com.wenlin.myproduction.binder;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.wenlin.myproduction.R;
import com.wenlin.myproduction.bean.Empty;
import com.wenlin.myproduction.util.Checker;
import com.wenlin.myproduction.util.UI;

import me.drakeet.multitype.ItemViewBinder;

/**
 * @author 文琳_377979485@qq.com
 * @time 2021/8/30 0030 上午 10:18
 * @desc 空数据样式
 */
public class EmptyBinder extends ItemViewBinder<Empty, EmptyBinder.EmptyHolder> {

    @NonNull
    @Override
    protected EmptyHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        return new EmptyHolder(inflater.inflate(R.layout.layout_empty, parent, false));
    }

    @Override
    protected void onBindViewHolder(@NonNull EmptyHolder holder, @NonNull Empty item) {
        if (Checker.hasWord(item.getName())) UI.setText(holder.tv, item.getName());
    }

    static class EmptyHolder extends RecyclerView.ViewHolder {
        TextView tv;

        public EmptyHolder(@NonNull View itemView) {
            super(itemView);
        }
    }
}
